package org.wattdepot.cli.command;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.wattdepot.cli.processor.CommandLineInterface;
import org.wattdepot.cli.processor.SourcesCommand;

/**
 * Test for the Sources command.
 * 
 * @author Kendyll Doi
 * @author Kimberly Heu
 * 
 */
public class TestSourcesCommand extends CommandLineInterface {

  /**
   * Tests the Sources methods.
   * 
   * @throws Exception If problems occur.
   */
  @Test
  public void testSourcesCommand() throws Exception {

    List<String> commandList = new ArrayList<String>(); // List of commands

    commandList.add("sources");

    SourcesCommand command = new SourcesCommand(); // command

    // The result from executing the individual method
    String methodResult = WattSources.wattSources(client);
    // The result from executing corresponding command
    String commandResult = command.doCommand(commandList);

    // Ensure answer is correct
    assertTrue("Checking method result", methodResult.contains("|Name             |Parent"));
    // Ensure both results are correct
    assertEquals("Checking method and command results are equal", methodResult, commandResult);
  }
}
